//
// Source code recreated from a .class file by IntelliJ IDEA
// (powered by FernFlower decompiler)
//

package com.hustcad.plm.pdm.workflow.controller;

import cn.hutool.extra.spring.SpringUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.feishu.base.type.ClassificationTypeEnum;
import com.feishu.base.type.OutJsonTypeEnum;
import com.feishu.rpc.core.SendHttpServer;
import com.feishu.service.FeiShuCommonService;
import com.github.pagehelper.PageInfo;
import com.hustcad.plm.pdm.flowbusiness.model.entity.FlowObject;
import com.hustcad.plm.pdm.flowbusiness.model.entity.WorkFlowObjectPackage;
import com.hustcad.plm.pdm.redislock.TyplmRedisLockService;
import com.hustcad.plm.pdm.user.model.dto.PdmUserDTO;
import com.hustcad.plm.pdm.workflow.model.constant.FlowRoleEnum;
import com.hustcad.plm.pdm.workflow.model.constant.WorkFlowErrorCodeEnum;
import com.hustcad.plm.pdm.workflow.model.entity.*;
import com.hustcad.plm.pdm.workflow.model.vo.FlowObjectDetailInfoVO;
import com.hustcad.plm.pdm.workflow.model.vo.FlowTaskRecordAndContentVO;
import com.hustcad.plm.pdm.workflow.model.vo.FlowTaskRecordVO;
import com.hustcad.plm.pdm.workflow.model.vo.FlowTerminalVO;
import com.hustcad.plm.pdm.workflow.model.vo.TyplmTaskVO;
import com.hustcad.plm.pdm.workflow.model.vo.WithdrawProcessVO;
import com.hustcad.plm.pdm.workflow.service.*;
import com.hustcad.plm.pdm.workflow.util.TyplmWorkFlowUtil;
import com.ty.basic.entity.CTyEntityBaseDO;
import com.ty.basic.entity.IdentifierEntity;
import com.ty.basic.handler.exceptionhandler.exception.ResponseCodeEnum;
import com.ty.basic.handler.exceptionhandler.exception.TyException;
import com.ty.basic.redislock.RedisLockService;
import com.ty.basic.response.ResponseResult;
import com.ty.basic.utils.ArgumentUtils;
import com.ty.basic.utils.controller.CommonQuery;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.annotation.Resource;
import org.apache.commons.lang3.ObjectUtils;
import org.apache.commons.lang3.StringUtils;
import org.springframework.transaction.annotation.Isolation;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@RestController
@Api(
        tags = {"流程服务"}
)
@RequestMapping({"/rest/v1/workFlowProcess"})
public class TyplmWorkFlowProcessController {
    @Resource
    private TyplmWorkFlowProcessService typlmWorkFlowProcessService;
    @Resource
    private TyplmFlowCommonService typlmFlowCommonService;
    @Resource
    private TyplmFlowableTaskService typlmFlowableTaskService;
    @Resource
    private TyplmWorkFlowService typlmWorkFlowService;
    @Resource
    private TyplmFlowContainerObjectService typlmFlowContainerObjectService;
    @Resource
    private TyplmFlowHandlerService typlmFlowHandlerService;
    @Resource
    private TyplmRedisLockService typlmRedisLockService;
    @Resource
    private RedisLockService redisLockService;
    @Resource
    private TyplmWorkFlowtOperateTaskService typlmWorkFlowtOperateTaskService;

    public TyplmWorkFlowProcessController() {
    }

    @PostMapping({"/queryMyToDoTaskPage"})
    @ApiOperation(
            value = "分页查询代办",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<PageInfo<FlowTaskInfo>> queryMyToDoTaskPage(@RequestBody CommonQuery commonQuery) {
        com.ty.basic.utils.controller.PageInfo pageInfo = commonQuery.getPageInfo();
        ArgumentUtils.checkArgumentEmpty(pageInfo, "分页参数");
        Map<String, Object> queryConditions = commonQuery.getQueryConditions();
        PageInfo<FlowTaskInfo> flowTaskInfoPage = this.typlmWorkFlowProcessService.queryMyToDoTaskPage(queryConditions, pageInfo.getCurPage(), pageInfo.getPageSize());
        return ResponseResult.success(flowTaskInfoPage);
    }

    @PostMapping({"/queryFlowManagerPage"})
    @ApiOperation(
            value = "查询可选的流程管理者",
            notes = "查询可选的流程管理者",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<PageInfo<PdmUserDTO>> queryFlowManagerPage(@RequestBody CommonQuery commonQuery) {
        Map<String, Object> queryConditions = commonQuery.getQueryConditions();
        if (ObjectUtils.isEmpty(queryConditions)) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[0]);
        }

        if (StringUtils.isBlank(String.valueOf(queryConditions.get("oid")))) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[]{"oid"});
        }

        if (StringUtils.isBlank(String.valueOf(queryConditions.get("otype")))) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[]{"otype"});
        }

        return ResponseResult.success(this.typlmFlowCommonService.queryFlowManagerPage(queryConditions));
    }

    @PostMapping({"/queryMyToDoTaskCount"})
    @ApiOperation(
            value = "我的待办任务总数",
            notes = "我的待办任务总数",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<Integer> queryMyToDoTaskCount() {
        return ResponseResult.success(this.typlmFlowableTaskService.queryMyToDoTaskCount());
    }

    @PostMapping({"/myDraftWorkFlowCount"})
    @ApiOperation(
            value = "我的流程草稿总数",
            notes = "我的流程草稿总数",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<Integer> myDraftWorkFlowCount() {
        return ResponseResult.success(this.typlmFlowableTaskService.myDraftWorkFlowCount());
    }

    @PostMapping({"/queryDeliverUserPageByTask"})
    @ApiOperation(
            value = "获取任务的可以转交人",
            notes = "获取任务的可以转交人",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<PageInfo<PdmUserDTO>> queryDeliverUserPageByTask(@RequestBody CommonQuery param) {
        Map<String, Object> queryConditions = param.getQueryConditions();
        if (ObjectUtils.isEmpty(queryConditions)) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[0]);
        }

        if (ObjectUtils.isEmpty(queryConditions.get("taskId"))) {
            TyException.throwSingleTyExceptionVarargs(ResponseCodeEnum.ACC_PARAMETER_IS_NULL, new String[]{"taskId"});
        }

        return ResponseResult.success(this.typlmWorkFlowProcessService.queryDeliverUserPageByTask(queryConditions));
    }

    @PostMapping({"/getFlowHandlerPage"})
    @ApiOperation(
            value = "当前流程节点的处理人(分页)",
            notes = "当前流程节点的处理人(分页)",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<PageInfo<PdmUserDTO>> getFlowHandlerPage(@RequestBody FlowHandlerDTO flowHandlerDTO) {
        return ResponseResult.success(this.typlmFlowHandlerService.getFlowHandlerPage(flowHandlerDTO, Boolean.FALSE, Boolean.TRUE, Boolean.TRUE));
    }

    @PostMapping({"/getOtherFlowHandlerPage"})
    @ApiOperation(
            value = "非当前流程节点的处理人（分页）",
            notes = "非当前流程节点的处理人（分页）",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<PageInfo<PdmUserDTO>> getOtherFlowHandlerPage(@RequestBody FlowHandlerDTO flowHandlerDTO) {
        return ResponseResult.success(this.typlmFlowHandlerService.getOtherFlowHandlerPage(flowHandlerDTO));
    }

    @Transactional(
            rollbackFor = {Exception.class}
    )
    @PostMapping({"/startProcess"})
    @ApiOperation(
            value = "启动流程",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<WorkFlowContainerView> startProcess(@RequestBody WorkFlowContainerView workFlowContainerView) {
        ArgumentUtils.checkArgumentNull(workFlowContainerView, "流程");
        ArgumentUtils.checkArgumentNull(workFlowContainerView.getOid(), "流程");
        String key = "adapter:lock:workflow:" + workFlowContainerView.getOid().toString();
        boolean hasLocked = this.redisLockService.hasLocked(key);
        if (hasLocked) {
            return ResponseResult.fail(WorkFlowErrorCodeEnum.FLOW_DO_NOT_SUBMIT_REPEATEDLY.getException(new Object[0]));
        } else {
            try {
                this.redisLockService.lock(key);
                this.typlmWorkFlowProcessService.startProcess(workFlowContainerView, true);
            } finally {
                this.redisLockService.unlock(key);
            }

            return ResponseResult.success(workFlowContainerView);
        }
    }

    @GetMapping({"/getTaskDetailView"})
    @ApiOperation(
            value = "根据任务ID获取任务的详情",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<FlowTaskInfo> getTaskDetailView(String taskId) {
        FlowTaskInfo taskDetailView = this.typlmWorkFlowProcessService.getTaskDetailView(taskId);
        this.typlmWorkFlowtOperateTaskService.setFlowNodeInfo(taskDetailView, (BigInteger)null, "flowTask");
        return ResponseResult.success(taskDetailView);
    }

    @GetMapping({"/getTaskSimpleView"})
    @ApiOperation(
            value = "根据任务ID获取任务的详情",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<FlowTaskInfo> getTaskSimpleView(String taskId) {
        FlowTaskInfo taskDetailView = this.typlmWorkFlowProcessService.getTaskDetailView(taskId, true);
        return ResponseResult.success(taskDetailView);
    }

    @Transactional(
            rollbackFor = {Exception.class},
            isolation = Isolation.READ_COMMITTED
    )
    @PostMapping({"/completeTask"})
    @ApiOperation(
            value = "处理任务",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<Boolean> completeTask(String flowTaskInfo, List<MultipartFile> fileList) {
        FlowTaskInfo flowTaskInfoObj = (FlowTaskInfo)JSON.parseObject(flowTaskInfo, FlowTaskInfo.class);
        ArgumentUtils.checkArgumentNull(flowTaskInfoObj.getTaskId(), "taskId");
        String key = "adapter:lock:workflow:" + flowTaskInfoObj.getTaskId();
        boolean hasLocked = this.typlmRedisLockService.hasLocked(key);
        if (hasLocked) {
            return ResponseResult.fail(WorkFlowErrorCodeEnum.TASK_DO_NOT_SUBMIT_REPEATEDLY.getException(new Object[0]));
        } else {
            try {
                this.typlmRedisLockService.lock(key);
                this.typlmWorkFlowProcessService.completeTask(flowTaskInfoObj, fileList);
            } finally {
                this.typlmRedisLockService.unlock(key);
            }

            return ResponseResult.success(true);
        }
    }

    @Transactional(
            rollbackFor = {Exception.class},
            isolation = Isolation.READ_COMMITTED
    )
    @PostMapping({"/quickCompleteTask"})
    @ApiOperation(
            value = "快速处理任务",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<Boolean> quickCompleteTask(String flowTaskInfo, List<MultipartFile> fileList) {
        FlowTaskInfo flowTaskInfoObj = (FlowTaskInfo)JSON.parseObject(flowTaskInfo, FlowTaskInfo.class);
        ArgumentUtils.checkArgumentNull(flowTaskInfoObj.getTaskId(), "taskId");
        String key = "adapter:lock:workflow:" + flowTaskInfoObj.getTaskId();
        boolean hasLocked = this.typlmRedisLockService.hasLocked(key);
        if (hasLocked) {
            return ResponseResult.fail(WorkFlowErrorCodeEnum.TASK_DO_NOT_SUBMIT_REPEATEDLY.getException(new Object[0]));
        } else {
            try {
                this.typlmRedisLockService.lock(key);
                this.typlmWorkFlowProcessService.completeTask(flowTaskInfoObj, fileList, false);
            } finally {
                this.typlmRedisLockService.unlock(key);
            }

            return ResponseResult.success(true);
        }
    }

    @Transactional(
            rollbackFor = {Exception.class}
    )
    @PostMapping({"/saveTask"})
    @ApiOperation(
            value = "保存任务",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<Boolean> saveTask(String flowTaskInfo, List<MultipartFile> fileList) {
        FlowTaskInfo flowTaskInfoObj = (FlowTaskInfo)JSON.parseObject(flowTaskInfo, FlowTaskInfo.class);
        this.typlmWorkFlowProcessService.saveTask(flowTaskInfoObj, fileList);
        return ResponseResult.success(true);
    }

    @Transactional(
            rollbackFor = {Exception.class}
    )
    @PostMapping({"/saveTaskUserList"})
    @ApiOperation(
            value = "保存任务的处理人",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<Boolean> saveTaskUserList(String flowTaskInfo) {
        FlowTaskInfo flowTaskInfoObj = (FlowTaskInfo)JSON.parseObject(flowTaskInfo, FlowTaskInfo.class);
        this.typlmWorkFlowProcessService.saveTaskUserList(flowTaskInfoObj);
        return ResponseResult.success(true);
    }

    @Transactional(
            rollbackFor = {Exception.class}
    )
    @PostMapping({"/deliverTask"})
    @ApiOperation(
            value = "转交任务",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<Boolean> deliverTask(@RequestBody DeliverTaskView deliverTaskView) {
        this.typlmWorkFlowProcessService.deliverTask(deliverTaskView);
        return ResponseResult.success(true);
    }

    /** @deprecated */
    @Deprecated
    @PostMapping({"/queryMyToDoTask"})
    @ApiOperation(
            value = "分页查询代办",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<PageInfo<FlowTaskInfo>> queryMyToDoTask(@RequestBody CommonQuery commonQuery) {
        com.ty.basic.utils.controller.PageInfo pageInfo = commonQuery.getPageInfo();
        ArgumentUtils.checkArgumentEmpty(pageInfo, "分页参数");
        Map<String, Object> queryConditions = commonQuery.getQueryConditions();
        PageInfo<FlowTaskInfo> flowTaskInfoPage = this.typlmWorkFlowProcessService.queryMyToDoTask(queryConditions, pageInfo.getCurPage(), pageInfo.getPageSize());
        return ResponseResult.success(flowTaskInfoPage);
    }

    @PostMapping({"/queryMoreTaskInfo"})
    @ApiOperation(
            value = "查询任务的更多信息",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<FlowTaskInfo> queryMoreTaskInfo(@RequestBody FlowTaskInfo flowTaskInfo) {
        ArgumentUtils.checkArgumentEmpty(flowTaskInfo.getProcessDefId(), "流程定义ID");
        ArgumentUtils.checkArgumentEmpty(flowTaskInfo.getTaskDefKey(), "流程任务定义KEY");
        ArgumentUtils.checkArgumentEmpty(flowTaskInfo.getWorkFlowContainerOid(), "流程容器OID");
        ArgumentUtils.checkArgumentEmpty(flowTaskInfo.getWorkFlowContainerOtype(), "流程容器OTYPE");
        ArgumentUtils.checkArgumentEmpty(flowTaskInfo.getWorkFlowContainerCreatorName(), "流程创建人");
        ArgumentUtils.checkArgumentEmpty(flowTaskInfo.getWorkFlowContainerCreatorUserName(), "流程创建人账号");
        ArgumentUtils.checkArgumentEmpty(flowTaskInfo.getExecutionId(), "执行实体ID");
        this.typlmWorkFlowProcessService.queryMoreTaskInfo(flowTaskInfo);
        return ResponseResult.success(flowTaskInfo);
    }

    /** @deprecated */
    @Deprecated
    @PostMapping({"/queryTaskList"})
    @ApiOperation(
            value = "根据条件查询任务列表",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<PageInfo<FlowTaskInfo>> queryTaskList(@RequestBody FolwTaskParam folwTaskParam) {
        PageInfo<FlowTaskInfo> flowTaskList = this.typlmWorkFlowProcessService.queryTaskList(folwTaskParam);
        return ResponseResult.success(flowTaskList);
    }

    /** @deprecated */
    @Deprecated
    @PostMapping({"/queryObjectProcessInfo"})
    @ApiOperation(
            value = "查询对象流程信息",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<PageInfo<FlowObjectDetailInfoVO>> queryObjectProcessInfo(@RequestBody JSONObject params) {
        PageInfo<FlowObjectDetailInfoVO> flowObjectDetailInfoList = this.typlmFlowContainerObjectService.queryObjectProcessInfo(params);
        return ResponseResult.success(flowObjectDetailInfoList);
    }

    /** @deprecated */
    @Deprecated
    @PostMapping({"/dealDone"})
    @ApiOperation(
            value = "分页查询已办",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<PageInfo<FlowTaskInfo>> dealDone(@RequestBody CommonQuery commonQuery) {
        if (commonQuery.getQueryConditions() == null) {
            commonQuery.setQueryConditions(new HashMap(8));
        }

        Map<String, Object> queryConditions = commonQuery.getQueryConditions();
        queryConditions.put("creatorOid", TyplmWorkFlowUtil.getUser().getOid());
        queryConditions.put("status", 1);
        return ResponseResult.success(this.typlmWorkFlowProcessService.queryWorkFlowDone(commonQuery));
    }

    /** @deprecated */
    @Deprecated
    @PostMapping({"/involvedFlowList"})
    @ApiOperation(
            value = "列出本人参与的已完成的流程任务）",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<PageInfo<FlowTaskInfo>> queryInvolvedFlowList(@RequestBody CommonQuery commonQuery) {
        if (commonQuery.getQueryConditions() == null) {
            commonQuery.setQueryConditions(new HashMap(8));
        }

        Map<String, Object> queryConditions = commonQuery.getQueryConditions();
        queryConditions.put("involvedCreatorOid", TyplmWorkFlowUtil.getUser().getOid());
        queryConditions.put("statusMore", 1);
        PageInfo<FlowTaskInfo> ret = this.typlmWorkFlowProcessService.queryInvolvedFlowList(commonQuery);
        Iterator var4 = ret.getList().iterator();

        while(var4.hasNext()) {
            FlowTaskInfo task = (FlowTaskInfo)var4.next();
            WorkFlow nonWorkFlow = this.typlmWorkFlowService.getNonWorkFlow(task.getFlowTemplateId());
            task.setFlowTemplate(nonWorkFlow.getName());
        }

        return ResponseResult.success(ret);
    }

    /** @deprecated */
    @Deprecated
    @PostMapping({"/myLaunchedProcess"})
    @ApiOperation(
            value = "我发起的流程列表",
            notes = "我发起的流程列表",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<PageInfo<FlowTaskInfo>> mySponsoredProcess(@RequestBody CommonQuery commonQuery) {
        if (commonQuery.getQueryConditions() == null) {
            commonQuery.setQueryConditions(new HashMap(8));
        }

        Map<String, Object> queryConditions = commonQuery.getQueryConditions();
        queryConditions.put("flowCreatorOid", TyplmWorkFlowUtil.getUser().getOid());
        queryConditions.put("status", 1);
        return ResponseResult.success(this.typlmWorkFlowProcessService.queryMyLaunchedFlowList(commonQuery));
    }

    /** @deprecated */
    @Deprecated
    @PostMapping({"/myFlowHandler"})
    @ApiOperation(
            value = "当前流程节点的处理人",
            notes = "当前流程节点的处理人",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<List<PdmUserDTO>> getFlowHandler(@RequestBody Map<String, String> queryConditions) {
        return ResponseResult.success(this.typlmFlowHandlerService.queryFlowHandler(queryConditions));
    }

    @PostMapping({"/terminalProcess"})
    @ApiOperation(
            value = "终止流程",
            notes = "终止流程",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<Boolean> terminalProcess(BigInteger workFlowContainerId) {
        this.typlmWorkFlowProcessService.terminalProcess(workFlowContainerId);
        return ResponseResult.success(true);
    }

    @PostMapping({"/terminalProcessV2"})
    @ApiOperation(
            value = "终止流程",
            notes = "终止流程",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<Boolean> terminalProcess(@RequestBody FlowTerminalVO flowTerminalVO) {
        FeiShuCommonService feiShuCommonService = SpringUtil.getBean(FeiShuCommonService.class);
        Map<String,Object> selectMap=new HashMap<>();
        selectMap.put("workFlowContainerId",flowTerminalVO.getWorkFlowContainerId().toString());
        List<Map<String,Object>> feishuCodeList=feiShuCommonService.getFeiShuApprovalCode(selectMap);
        if(feishuCodeList.size()>0){
            SendHttpServer sendHttpServer = SpringUtil.getBean(SendHttpServer.class);
            TyplmWorkFlowContainerService typlmWorkFlowContainerService=SpringUtil.getBean(TyplmWorkFlowContainerService.class);
            WorkFlowContainerView workFlowContainerView = typlmWorkFlowContainerService.getWorkFlowContainerDetailByPrimaryKey(flowTerminalVO.getWorkFlowContainerId());
            if (workFlowContainerView instanceof WorkFlowObjectPackage){
                WorkFlowObjectPackage workFlowObjectPackage = (WorkFlowObjectPackage) workFlowContainerView;

                if(workFlowObjectPackage.getFlowObjectList()!=null && workFlowObjectPackage.getFlowObjectList().size()>0){
                    FlowObject flowObject = null;
                    for(int i=0;i<workFlowObjectPackage.getFlowObjectList().size();i++){
                        flowObject=workFlowObjectPackage.getFlowObjectList().get(i);
                        String oType = flowObject.getRefObjectOtype();
                        if("ty.inteplm.part.CTyPart".equals(oType)){
                            break;
                        }
                        else if("ty.inteplm.form.CTyFormData".equals(oType)){
                            break;
                        }
                    }
                    String taskId= (String) feishuCodeList.get(0).get("task_id");
                    String approval_code= (String) feishuCodeList.get(0).get("approval_code");
                    String process_instance_id= (String) feishuCodeList.get(0).get("process_instance_id");
                    String submit_id= (String) feishuCodeList.get(0).get("submit_id");
                    String approval_id= (String) feishuCodeList.get(0).get("approval_id");
                    String audit= (String) feishuCodeList.get(0).get("audit");
                    String executionstrategyStr= (String) feishuCodeList.get(0).get("executionstrategy");
                    JSONObject executionstrategy=JSONObject.parseObject(executionstrategyStr);

                    Map<String,Object> threadMap=new HashMap<>();
                    threadMap.put("synCode","FSSYNC00026X");
                    threadMap.put("synObject","飞书同步三方审批");
                    threadMap.put("audit",audit);
                    threadMap.put("auditStatus","TERMINATED");
                    threadMap.put("instance_id",process_instance_id);
                    threadMap.put("start_time",System.currentTimeMillis());
                    threadMap.put("end_time",System.currentTimeMillis());
                    threadMap.put("code",workFlowContainerView.getCode());
                    threadMap.put("name",workFlowContainerView.getName());
                    threadMap.put("creatorAccount",workFlowContainerView.getCreatorAccount());
                    threadMap.put("workFlowName",workFlowContainerView.getWorkFlowName());
                    threadMap.put("emergencyDegreeName",workFlowContainerView.getEmergencyDegreeName());
                    threadMap.put("taskId",taskId);
                    threadMap.put("processInstanceId",process_instance_id);
                    threadMap.put("submitId",submit_id);
                    threadMap.put("executionstrategy",executionstrategy);
                    threadMap.put("feishuCodeList",feishuCodeList);
                    threadMap.put("approval_code",approval_code);
                    threadMap.put("approvalId",approval_id);

                    JSONObject resultHttp=sendHttpServer.sendUserDataToChangeServer("FSSYNC00026X",
                                                                                    "飞书同步三方审批",
                                                                                    OutJsonTypeEnum.OUT_JSON_TYPE_FEISHU,
                                                                                    ClassificationTypeEnum.DEFAULT.setValue("ordinaryMessage"),
                                                                                    flowObject, threadMap);
                }
            }
        }
        this.typlmWorkFlowProcessService.terminalProcess(flowTerminalVO);
        return ResponseResult.success(true);
    }

    @PostMapping({"/querySupervisoryFlow"})
    @ApiOperation(
            value = "查询监控的流程",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<PageInfo<FlowTaskInfo>> querySupervisoryFlow(@RequestBody CommonQuery commonQuery) {
        ArgumentUtils.checkArgumentEmpty(commonQuery.getPageInfo(), "分页参数");
        PageInfo<FlowTaskInfo> flowTaskInfoPage = this.typlmWorkFlowProcessService.querySupervisoryFlow(commonQuery, FlowRoleEnum.MONITOR.getUsage());
        return ResponseResult.success(flowTaskInfoPage);
    }

    @PostMapping({"/countSupervisoryFlow"})
    @ApiOperation(
            value = "统计监控的流程",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<Integer> countSupervisoryFlow(@RequestBody CommonQuery commonQuery) {
        Integer count = this.typlmWorkFlowProcessService.countWorkFlowByParams(commonQuery.getQueryConditions(), FlowRoleEnum.MONITOR.getUsage());
        return ResponseResult.success(count);
    }

    @PostMapping({"/queryManageFlow"})
    @ApiOperation(
            value = "查询管理的流程",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<PageInfo<FlowTaskInfo>> queryManageFlow(@RequestBody CommonQuery commonQuery) {
        ArgumentUtils.checkArgumentEmpty(commonQuery.getPageInfo(), "分页参数");
        PageInfo<FlowTaskInfo> flowTaskInfoPage = this.typlmWorkFlowProcessService.querySupervisoryFlow(commonQuery, FlowRoleEnum.MANAGER.getUsage());
        return ResponseResult.success(flowTaskInfoPage);
    }

    @PostMapping({"/queryTableSupervisoryFlow"})
    @ApiOperation(
            value = "查询监控的流程(列表方式)",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<PageInfo<FlowTaskInfo>> queryTableSupervisoryFlow(@RequestBody CommonQuery commonQuery) {
        ArgumentUtils.checkArgumentEmpty(commonQuery.getPageInfo(), "分页参数");
        PageInfo<FlowTaskInfo> flowTaskInfoPage = this.typlmWorkFlowProcessService.queryTableSupervisoryFlow(commonQuery, FlowRoleEnum.MONITOR.getUsage());
        return ResponseResult.success(flowTaskInfoPage);
    }

    @PostMapping({"/queryTableManageFlow"})
    @ApiOperation(
            value = "查询管理的流程(列表方式)",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<PageInfo<FlowTaskInfo>> queryTableManageFlow(@RequestBody CommonQuery commonQuery) {
        ArgumentUtils.checkArgumentEmpty(commonQuery.getPageInfo(), "分页参数");
        PageInfo<FlowTaskInfo> flowTaskInfoPage = this.typlmWorkFlowProcessService.queryTableSupervisoryFlow(commonQuery, FlowRoleEnum.MANAGER.getUsage());
        return ResponseResult.success(flowTaskInfoPage);
    }

    @PostMapping({"/countManageFlow"})
    @ApiOperation(
            value = "统计管理的流程",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<Integer> countManageFlow(@RequestBody CommonQuery commonQuery) {
        Integer count = this.typlmWorkFlowProcessService.countWorkFlowByParams(commonQuery.getQueryConditions(), FlowRoleEnum.MANAGER.getUsage());
        return ResponseResult.success(count);
    }

    @PostMapping({"/getParticipantsNewInfo"})
    @ApiOperation(
            value = "获取参与者的最新信息",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<List<ParticipantsDTO>> getParticipantsNewInfo(@RequestBody List<ParticipantsDTO> participants) {
        return ResponseResult.success(this.typlmWorkFlowProcessService.getParticipantsNewInfo(participants));
    }

    @GetMapping({"/processRecord/{processInstanceId}"})
    @ApiOperation(
            value = "根据流程实例id获取流程记录",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<Map<String, List<String>>> processRecord(@PathVariable("processInstanceId") String processInstanceId) {
        return ResponseResult.success(this.typlmWorkFlowProcessService.processRecord(processInstanceId));
    }

    @GetMapping({"/getActiveTaskListByProcessInstanceId/{processInstanceId}"})
    @ApiOperation(
            value = "获取执行中的节点名称",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<List<TyplmTaskVO>> getActiveTaskListByProcessInstanceId(@PathVariable("processInstanceId") String processInstanceId) {
        return ResponseResult.success(this.typlmWorkFlowProcessService.getActiveTaskList(processInstanceId));
    }

    @PostMapping({"/batchQueryEntityListWorkFlowContainer"})
    @ApiOperation(
            value = "根据对象获取工作流程容器oid",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<Map<String, Set<BigInteger>>> batchQueryEntityListWorkFlowContainer(@RequestBody List<IdentifierEntity> entityList) {
        Map<IdentifierEntity, CTyEntityBaseDO> entityMap = TyplmWorkFlowUtil.getEntityMap(entityList);
        Map<String, Set<BigInteger>> objFlowContainerMap = this.typlmFlowContainerObjectService.batchQueryEntityListWorkFlowContainer(new ArrayList(entityMap.values()));
        return ResponseResult.success(objFlowContainerMap);
    }

    @PostMapping({"/listObjectProcessInfo"})
    @ApiOperation(
            value = "查询对象流程信息(不分页)",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<List<FlowObjectDetailInfoVO>> listObjectProcessInfo(@RequestBody JSONObject params) {
        List<FlowObjectDetailInfoVO> flowObjectDetailInfoList = this.typlmFlowContainerObjectService.listObjectProcessInfo(params);
        return ResponseResult.success(flowObjectDetailInfoList);
    }

    @PostMapping({"/withdrawProcess"})
    @ApiOperation(
            value = "撤回流程至草稿状态",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<Boolean> withdrawProcess(@RequestBody WithdrawProcessVO withdrawProcessVO) {
        this.typlmWorkFlowProcessService.withdrawProcess(withdrawProcessVO);
        return ResponseResult.success();
    }

    @PostMapping({"/queryFlowTaskRecordForCurrentbatch"})
    @ApiOperation(
            value = "查询当前批次的审批记录和所有附件",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<FlowTaskRecordAndContentVO> queryFlowTaskRecordForCurrentbatch(@RequestBody FlowTaskRecordVO flowTaskRecordVO) {
        return ResponseResult.success(this.typlmWorkFlowProcessService.queryFlowTaskRecordForCurrentbatch(flowTaskRecordVO.getTaskdefkeys(), flowTaskRecordVO.getWorkFlowContainerOid()));
    }

    @Transactional(
            rollbackFor = {Exception.class}
    )
    @PostMapping({"/saveFlowTask"})
    @ApiOperation(
            value = "保存任务",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<Boolean> saveFlowTask(@RequestBody String flowTaskInfo) {
        FlowTaskInfo flowTaskInfoObj = (FlowTaskInfo)JSON.parseObject(flowTaskInfo, FlowTaskInfo.class);
        this.typlmWorkFlowProcessService.saveFlowTask(flowTaskInfoObj, flowTaskInfoObj.getContentUploadVaultVOS(), flowTaskInfoObj.getNeedDeleteVaultitemOidList(), flowTaskInfoObj.getNeedDeleteContentDataOidList());
        return ResponseResult.success(true);
    }

    @Transactional(
            rollbackFor = {Exception.class}
    )
    @PostMapping({"/cancelSaveFlowTask"})
    @ApiOperation(
            value = "取消保存任务",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<Boolean> cancelSaveFlowTask(@RequestBody List<BigInteger> vaultitemOidList) {
        this.typlmWorkFlowProcessService.cancelSaveFlowTask(vaultitemOidList);
        return ResponseResult.success(true);
    }

    @PostMapping({"/queryFlowTaskRecord"})
    @ApiOperation(
            value = "查询任务实例的附件和审批记录",
            produces = "application/json; charset=utf-8"
    )
    public ResponseResult<List<FlowTaskRecord>> queryFlowTaskRecord(@RequestBody BigInteger workFlowContainerOid) {
        return ResponseResult.success(this.typlmWorkFlowProcessService.queryFlowTaskRecord(workFlowContainerOid));
    }
}
